Ext.define('DragonApp.view.user.Window', {
    extend: 'Ext.window.Window',
    alias: 'widget.user_window',
    layout: 'center',
    bind: {
        title: '{title}'
    },
    reference: 'user_window',
    modal: true,
    items: [{
        xtype: 'form',
        reference: 'form',
        padding: 10,

        modelValidation: true,

        layout: {
            type: 'fit',
            align: 'stretch'
        },
        items: [{
            xtype: 'fieldset',
            width: 380,
            title: '用户信息',
            layout: 'anchor',
            padding: '15 20 15 20',
            defaults: {
                afterLabelTextTpl: DragonApp.util.String.required,
                anchor: '100%',
                xtype: 'textfield',
                msgTarget: 'side',
                labelWidth: 75
            },
            items: [{
                    xtype: 'hiddenfield',
                    name: 'id',
                    fieldLabel: 'Label'
                },
                {
                    fieldLabel: '登录账号',
                    name: 'user'
                },
                {
                    fieldLabel: '用户姓名',
                    name: 'cname'
                },
                {
                    fieldLabel: '登录口令',
                    name: 'pass'
                },
                {
                    xtype: 'combo',
                    fieldLabel: '用户角色',
                    displayField: 'role_name',
                    valueField: 'id',
                    queryMode: 'local',
                    forceSelection: true,
                    editable: false,
                    name: 'role',
                    emptyText: '请选择',
                    store: Ext.create('Ext.data.Store', {
                        fields: ['id', 'role_name'],
                        data: [
                            { 'id': 1, 'role_name': '超级用户' },
                            { 'id': 2, 'role_name': '管理用户' },
                            { 'id': 3, 'role_name': '查询用户' }
                        ]
                    })
                }
            ]
        }]
    }],
    dockedItems: [{
        xtype: 'toolbar',
        dock: 'bottom',
        ui: 'footer',
        layout: {
            pack: 'end',
            type: 'hbox'
        },
        items: [{
            xtype: 'button',
            text: '取消',
            handler: 'onCancel',
            iconCls: 'x-fa fa-times'
        }, {
            iconCls: 'x-fa fa-check',
            handler: 'onSave',
            xtype: 'button',
            text: '保存'
        }]
    }]
});